Skip to content

[PWGJE] Added weighted-MC processes for jet background analysis - #18754

Open
choich08365 wants to merge 3 commits into
AliceO2Group:masterfrom
choich08365:gnnbjet
Open

choich08365 wants to merge 3 commits into
AliceO2Group:masterfrom
choich08365:gnnbjet

Conversation

@choich08365

Copy link
Copy Markdown
Contributor

Dear @aimeric-landou, @nzardosh, and @YubiaoWang,

I've drafted an update to the jet background analysis task, which enables the analysis on jet–jet MC. Could you please review it when you have time?
Thanks in advance!

PWGJE/Tasks/jetBackgroundAnalysis.cxx

  • Add processRhoMCDWeighted, processRhoMCPWeighted, processBkgFluctuationsMCDWeighted, and processBkgFluctuationsMCPWeighted.
  • Apply weighted MC outlier rejection using JCollisionOutliers and JMcCollisionOutliers.
  • Add applyMCDSelectionToMCP option. When enabled, require the matched MCD collision to pass the same event selection as MCD processes. This change is necessary for validating the unfolding of jet pT spectra with underlying-event subtraction, in my opinion.
  • Apply particle selections consistently to random-cone calculations.

PWGJE/Core/JetFindingUtilities.h

  • Extract particle status and charge selections from analyseParticles into the shared isParticleSelected function.

@github-actions github-actions Bot added the pwgje label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 11 warnings, 🔕 0 disabled

@github-actions github-actions Bot changed the title Added weighted-MC processes for jet background analysis [PWGJE] Added weighted-MC processes for jet background analysis Nov 15, 2026
@choich08365
choich08365 marked this pull request as ready for review November 15, 2026 12:21
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for 0782eb3 at 2026-11-15 13:58:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'To reproduce the results below locally, run: '\''aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'\''.'
To reproduce the results below locally, run: 'aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'.
++ echo 'To apply all automatic fixes, add the '\''-e O2PHYSICS_CHECKER_FIX=1'\'' option.'
To apply all automatic fixes, add the '-e O2PHYSICS_CHECKER_FIX=1' option.
++ echo 'See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.'
See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.
++ echo 'Found 2 errors and 8 warnings.'
Found 2 errors and 8 warnings.
++ [[ 2 -gt 0 ]]
++ cat /sw/BUILD/7d754585e85507907fd9c89ee68fa9425526b35b/O2Physics-code-check/errors.txt
PWGJE/Core/JetFindingUtilities.h:41:1: error: included header utility is not used directly [misc-include-cleaner,-warnings-as-errors]
PWGJE/Tasks/jetBackgroundAnalysis.cxx:255:96: error: no header providing "JetType" is directly included [misc-include-cleaner,-warnings-as-errors]
++ [[ 8 -gt 0 ]]
++ cat /sw/BUILD/7d754585e85507907fd9c89ee68fa9425526b35b/O2Physics-code-check/warnings.txt
PWGJE/Core/JetFindingUtilities.h:44:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead [modernize-deprecated-headers]
PWGJE/Core/JetFindingUtilities.h:272:12: warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]
PWGJE/Core/JetFindingUtilities.h:273:5: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGJE/Core/JetFindingUtilities.h:346:80: warning: repeated branch body in conditional chain [bugprone-branch-clone]
PWGJE/Core/JetFindingUtilities.h:348:5: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGJE/Core/JetFindingUtilities.h:428:5: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGJE/Tasks/jetBackgroundAnalysis.cxx:48:8: warning: constructor does not initialize these fields: pdgDatabase [cppcoreguidelines-pro-type-member-init]
PWGJE/Tasks/jetBackgroundAnalysis.cxx:75:24: warning: initializer for member 'randomNumber' is redundant [readability-redundant-member-init]
++ [[ 2 -gt 0 ]]
++ exit 1
--

Full log here.

Comment thread PWGJE/Core/JetFindingUtilities.h Outdated
* Kinematic acceptance cuts are applied to the input particle table separately.
*/
template <typename T, typename U>
bool isParticleSelected(T const& particle, const std::string& particleSelection, int jetTypeParticleLevel, U const& pdgDatabase)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should replace this block in analyseParticles with this new function so that anywhere that the code changes it changes for both

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nzardosh, thanks for your comment. In this commit, it seems that they are already replaced with isParticleSelected function in analyseParticles.

Comment thread PWGJE/Core/JetFindingUtilities.h Outdated
if (std::isinf(particle.eta())) {
return false;
}
auto pdgParticle = pdgDatabase->GetParticle(particle.pdgCode());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of giving the function the pdgDatabse you could get the pdgParticle before the function is called and give it to the function instead. It avoids having the pdgParticle retrieved twice from the database

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nzardosh, I've overloaded the function isParticleSelected to output pdgParticle as a pointer parameter.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better that pdgParticle is given as an input to the function instead. Also currently you set it to a nullptr

@choich08365 choich08365 Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep the line pdgDatabase->GetParticle(particle.pdgCode()) inside isParticleSelected. This function is also called directly by jetBackgroundAnalysis.cxx, where the caller does not otherwise need pdgParticle. Making it an input would require those callers to perform a lookup solely to pass the result back into the selection function.
Since pdgParticle is derived from particle and pdgDatabase, exposing it as an additional input feels redundant. In analyseParticles, it is only needed afterward to obtain the PDG mass; the overload allows us to reuse the lookup for that purpose.
The initial nullptr assignment resets the output pointer before any early return. It is populated by GetParticle() once the status and eta checks pass.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but in any case whether pdgDatabase->GetParticle(particle.pdgCode()) is done in the function or before, it has to anyways be called. And like this in analyseParticles it doesnt need to be called twice which it currently is since the id is needed for the mass

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling the overloaded wrapper function adds negligible overhead. This implementation allows analyseParticles() to reuse the PDG pointer for the mass, while callers in jetBackgroundAnalysis.cxx do not need to handle a pointer they otherwise have no use for. I consider keeping that implementation detail out of those callers a reasonable encapsulation choice.

@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for 7bb0eb2 at 2026-11-16 14:19:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'To reproduce the results below locally, run: '\''aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'\''.'
To reproduce the results below locally, run: 'aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'.
++ echo 'To apply all automatic fixes, add the '\''-e O2PHYSICS_CHECKER_FIX=1'\'' option.'
To apply all automatic fixes, add the '-e O2PHYSICS_CHECKER_FIX=1' option.
++ echo 'See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.'
See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.
++ echo 'Found 1 errors and 7 warnings.'
Found 1 errors and 7 warnings.
++ [[ 1 -gt 0 ]]
++ cat /sw/BUILD/5088b9d8d5bfb4d6748c3bb0c339e32d7d1dee51/O2Physics-code-check/errors.txt
PWGJE/Core/JetFindingUtilities.h:297:84: error: no header providing "o2::constants::math::PI" is directly included [misc-include-cleaner,-warnings-as-errors]
++ [[ 7 -gt 0 ]]
++ cat /sw/BUILD/5088b9d8d5bfb4d6748c3bb0c339e32d7d1dee51/O2Physics-code-check/warnings.txt
PWGJE/Core/JetFindingUtilities.h:270:12: warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]
PWGJE/Core/JetFindingUtilities.h:271:5: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGJE/Core/JetFindingUtilities.h:345:80: warning: repeated branch body in conditional chain [bugprone-branch-clone]
PWGJE/Core/JetFindingUtilities.h:347:5: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGJE/Core/JetFindingUtilities.h:437:5: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGJE/Tasks/jetBackgroundAnalysis.cxx:49:8: warning: constructor does not initialize these fields: pdgDatabase [cppcoreguidelines-pro-type-member-init]
PWGJE/Tasks/jetBackgroundAnalysis.cxx:76:24: warning: initializer for member 'randomNumber' is redundant [readability-redundant-member-init]
++ [[ 1 -gt 0 ]]
++ exit 1
--

Full log here.

Comment thread PWGJE/Core/JetFindingUtilities.h Outdated
template <typename T, typename U>
bool isParticleSelected(T const& particle, const std::string& particleSelection, int jetTypeParticleLevel, U const& pdgDatabase, TParticlePDG const*& pdgParticle)
{
pdgParticle = nullptr;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need to be there?

Comment thread PWGJE/Core/JetFindingUtilities.h Outdated
}
if (jetTypeParticleLevel == static_cast<int>(JetType::neutral) && pdgCharge != 0.0) {
TParticlePDG const* pdgParticle = nullptr;
if (!isParticleSelected(particle, particleSelection, jetTypeParticleLevel, pdgDatabase, pdgParticle) || pdgParticle == nullptr) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the second check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments. I’ll need to rerun the O2 builders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants